package day16.feifei;

import java.util.Arrays;

public class Demo04 implements Comparable<Demo04>{
    private Integer number;
    private String name;

    public Demo04() {
    }

    public Demo04(Integer number, String name) {
        this.number = number;
        this.name = name;
    }

    /**
     * 获取
     * @return number
     */
    public Integer getNumber() {
        return number;
    }

    /**
     * 设置
     * @param number
     */
    public void setNumber(Integer number) {
        this.number = number;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    public String toString() {
        return "Demo04{number = " + number + ", name = " + name + "}";
    }

    @Override
    public int compareTo(Demo04 o) {
        return this.number.compareTo(o.number);
    }
}
class Main{
    public static void main(String[] args) {
        Demo04[] demo04=new Demo04[4];
        demo04[0]=new Demo04(1,"0000");
        demo04[1]=new Demo04(2,"0001");
        demo04[2]=new Demo04(4,"0002");
        demo04[3]=new Demo04(5,"0003");
        Demo04 s1=new Demo04(3,"0004");
        int i = Arrays.binarySearch(demo04, s1);
        System.out.println(i);
    }
}
